'use strict';

module.exports = app => {
  const { Sequelize } = app;

  const GoodsFigures = app.model.define('GoodsFigures', {
    id: {
      allowNull: false,
      autoIncrement: true,
      primaryKey: true,
      type: Sequelize.INTEGER
    },
    image: {
      allowNull: false,
      type: Sequelize.STRING(255)
    },
    figcaption: {
      allowNull: false,
      type: Sequelize.STRING(255)
    },
    goodsId: {
      type: Sequelize.INTEGER,
      allowNull: false,
      onDelete: "CASCADE",
      onUpdate: "CASCADE",
      references: {
        model: 'Goods',
        key: 'id'
      }
    },
  }, {
    timestamps: false,
    charset: 'utf8mb4',
    collate: 'utf8mb4_general_ci',
    comment: '商品图片表'
  });

  return GoodsFigures;

};